home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / fm2utils.zip / makeobj.cmd < prev    next >
OS/2 REXX Batch file  |  1995-12-31  |  2KB  |  73 lines

  1. /* Makes a WPS object out of the filename it receives as an argument. */
  2.  
  3. isprg = 0
  4. isicon = 0
  5. isptr = 0
  6. isbmp = 0
  7. setup = ''
  8. parse arg filename
  9. mydir = directory()
  10. filename = strip(filename)
  11. if filename \= '' then
  12. do
  13.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  14.   call SysLoadFuncs
  15.   rc = stream(filename,'c','query exists')
  16.   if rc \= '' then
  17.   do
  18.     ext = right(rc,length(rc) - lastpos(".",rc))
  19.     parse upper var ext ext
  20.     if ext = 'EXE' then isprg = 1
  21.     else if ext = 'COM' then isprg = 1
  22.     else if ext = 'CMD' then isprg = 1
  23.     else if ext = 'BAT' then isprg = 1
  24.     else if ext = 'ICO' then isicon = 1
  25.     else if ext = 'PTR' then isptr = 1
  26.     else if ext = 'BMP' then isbmp = 1
  27.     if isprg \= 0 then
  28.     do
  29.       /* create program objects for programs */
  30.       setup = 'EXENAME='rc';PARAMETERS=%*'
  31.       type = 'WPProgram'
  32.     end
  33.     else
  34.     do
  35.       /* create shadows for everything else */
  36.       type = 'WPShadow'
  37.       setup = 'SHADOWID='rc
  38.     end
  39.     title = right(rc,length(rc) - lastpos("\",rc))
  40.     if lastpos(".",title) \= 0 then
  41.     do
  42.       temp = left(title,lastpos(".",title) - 1)
  43.       if temp \= '' then title = temp
  44.     end
  45.     call SysCreateObject type,title,'<WP_DESKTOP>',setup,f
  46.   end
  47.   else   /* handle directories */
  48.   do
  49.     rc = directory(filename)
  50.     if rc \= '' then
  51.     do
  52.       call directory mydir
  53.       type = 'WPShadow'
  54.       setup = 'SHADOWID='rc
  55.       title = right(rc,length(rc) - lastpos("\",rc))
  56.       if title = '' then title = right(rc,length(rc) - lastpos(":",rc))
  57.       if lastpos(".",title) \= 0 then
  58.       do
  59.         temp = left(title,lastpos(".",title) - 1)
  60.         if temp \= '' then title = temp
  61.       end
  62.       call SysCreateObject type,title,'<WP_DESKTOP>',setup,f
  63.     end
  64.     else say "Can't find "filename"."
  65.   end
  66. end
  67. else
  68. do
  69.   say 'Usage:  MAKEOBJ filename'
  70.   say ' Creates a WPS object on the desktop for the filename.'
  71.   say ' Excellent for drag and drop use.'
  72. end
  73.